<?
include_once "accesscontrol.php";

if (isset($_POST[s1]))
{
	$q1 = "update job_employer_info set
						ContactName = '$_POST[ContactName]',
						position = '$_POST[position]',
						YearEstablished = '$_POST[YearEstablished]',
						website = '$_POST[web]',
						capital = '$_POST[capital]',
						employees = '$_POST[employees]',
						CompanyName = \"$_POST[CompanyName]\", 
						CompanyProfile = \"$_POST[CompanyProfile]\",
						CompanyCountry = \"$_POST[CompanyCountry]\", 
						CompanyState = \"$_POST[CompanyState]\",
						CompanyZip = \"$_POST[CompanyZip]\", 
						CompanyCity = \"$_POST[CompanyCity]\",
						street = \"$_POST[street]\",
						CompanyAddress = \"$_POST[CompanyAddress]\", 
						CompanyPhone = \"$_POST[CompanyPhone]\", 
						CompanyPhone2 = \"$_POST[CompanyPhone2]\", 
						fax = \"$_POST[fax]\",
						CompanyEmail = \"$_POST[CompanyEmail]\"
						
						where ename = '$_GET[ename]' ";


	$r1 = mysql_query($q1);

	if(!mysql_error())
	{
		echo "<center><span class=TNA>The prifile was updated!</span></center>";
	}

}

//get the employer info
$q1 = "select * from job_employer_info where ename = '$_GET[ename]' ";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);

?>


<br>

<script>

function CheckEmployer() {

	if(document.f1.ContactName.value=="")
	{
		alert('Enter a contact name, please!');
		document.f1.ContactName.focus();
		return false;
	}

	if(document.f1.position.value=="")
	{
		alert('Select your position, please!');
		document.f1.position.focus();
		return false;
	}

	if(document.f1.CompanyName.value=="")
	{
		alert('Enter your company name, please!');
		document.f1.CompanyName.focus();
		return false;
	}

	if(document.f1.CompanyCountry.value=="")
	{
		alert('Select your company country, please!');
		document.f1.CompanyCountry.focus();
		return false;
	}

	if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.f1.CompanyEmail.value))
	{
		alert("Invalid E-mail Address! Please re-enter.");
		document.f1.CompanyEmail.value="";
		document.f1.CompanyEmail.focus();
		return false;
	}

	if(document.f1.epass.value=="")
	{
		alert('Enter your password, please!');
		document.f1.epass.focus();
		return false;
	}

	if(document.f1.cpass.value=="")
	{
		alert('Confirm your password, please!');
		document.f1.cpass.focus();
		return false;
	}

	if(document.f1.epass.value != "" && document.f1.cpass.value != "" && document.f1.epass.value != document.f1.cpass.value)
	{
		alert('Enter and confirm your password again!');
		document.f1.epass.value="";
		document.f1.cpass.value="";
		document.f1.epass.focus();
		return false;
	}

}

</script>

<form method=post onsubmit="return CheckEmployer();" name=f1>
<table align=center width=420 cellspacing=0 class=BlackText border=0>
<caption align=center class=HeaderClass>Edit your info</caption>

<tr>
	<td colspan=2 class=BlackLink bgcolor=dddddd>Company details</td>
</tr>

<tr>
	<td width=150 align=right>Contact name<font color=red>*</font></td>
	<td width=370><input type=text name=ContactName value="<?=$a1[ContactName]?>"></td>
</tr>

<tr>
	<td align=right>Position<font color=red>*</font></td>
	<td>
		<select name="position">
              <option value="Owner" <? if($a1[position] == "Owner") { echo "selected"; } ?>>Owner</option>
              <option value="Director" <? if($a1[position] == "Director") { echo "selected"; } ?>>Director</option>
              <option value="HR Director" <? if($a1[position] == "HR Director") { echo "selected"; } ?>>HR Director</option>
              <option value="HR Manager" <? if($a1[position] == "HR Manager") { echo "selected"; } ?>>HR Manager</option>
              <option value="HR Assistant" <? if($a1[position] == "HR Assistant") { echo "selected"; } ?>>HR Assistant</option>
        </select>
	</td>
</tr>

<tr>
	<td align=right>Company name (legal)<font color=red>*</font></td>
	<td><input type=text name=CompanyName value="<?=$a1[CompanyName]?>"></td>
</tr>

<tr>
	<td align=right>Company Profile</td>
	<td><textarea rows=6 cols=35 name=CompanyProfile ><?=$a1[CompanyProfile]?></textarea></td>
</tr>

<tr>
	<td align=right>Year Established</td>
	<td><input type=text name=YearEstablished size=5 maxlength=4 value="<?=$a1[YearEstablished]?>"></td>
</tr>

<tr>
	<td align=right>Website</td>
	<td><input type=text name=web value="<?=$a1[website]?>"></td>
</tr>

<tr>
	<td align=right>Reg. capital</td>
	<td><input type=text name=capital value="<?=$a1[capital]?>" size=10></td>
</tr>

<tr>
	<td align=right>No. employees</td>
	<td><input type=text name=employees size=10 maxlength=10 value="<?=$a1[employees]?>"></td>
</tr>

<tr>
	<td colspan=2 class=BlackLink bgcolor=dddddd>Company address</td>
</tr>

<tr>
	<td align=right>Address</td>
	<td><input type=text name=CompanyAddress value="<?=$a1[CompanyAddress]?>"></td>
</tr>

<tr>
	<td align=right>Street</td>
	<td><input type=text name=street value="<?=$a1[street]?>"></td>
</tr>

<tr>
	<td align=right>Town/city</td>
	<td><input type=text name=CompanyCity value="<?=$a1[CompanyCity]?>"></td>
</tr>

<tr>
	<td align=right>State/County/Province:</td>
	<td><input type=text name=CompanyState value="<?=$a1[CompanyState]?>"></td>
</tr>

<tr>
	<td align=right>Country:<font color=red>*</font></td>
	<td><?=select_country($a1[CompanyCountry], "CompanyCountry");?></td>
</tr>

<tr>
	<td align=right>Zip/Postal code</td>
	<td><input type=text name=CompanyZip value="<?=$a1[CompanyZip]?>"></td>
</tr>

<tr>
	<td align=right>Telephone</td>
	<td><input type=text name=CompanyPhone value="<?=$a1[CompanyPhone]?>"></td>
</tr>

<tr>
	<td align=right>Mobile number</td>
	<td><input type=text name=CompanyPhone2 value="<?=$a1[CompanyPhone2]?>"></td>
</tr>

<tr>
	<td align=right>Fax number</td>
	<td><input type=text name=fax value="<?=$a1[fax]?>"></td>
</tr>

<tr>
	<td align=right>E-mail<font color=red>*</font></td>
	<td><input type=text name=CompanyEmail size=34 value="<?=$a1[CompanyEmail]?>"></td>
</tr>

<tr>
	<td>&nbsp;</td>
	<td align=left><input type=submit name=s1 value="Update"></td>
</tr>
	
</table>
	
</form>

<center>
	<a href="cinfo.php?ename=<?=$_GET[ename]?>" class=TNA>Back to the employer info page</a>

	<br><br>
</center>



<? include_once('../footer.php'); ?>